<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
<h:head>
    <link href="../../css/component.css" rel="stylesheet" type="text/css"/>
</h:head>

<!-- <ui:param name="bean" value="#{biMonitorConfigAction}" /> -->
<h:body>
    <script type="text/javascript">
        function hidedive() {
            var s = document.getElementById("datalist:startall");
            s.style.display = "none";
        }
        function showdive() {
            var s = document.getElementById("datalist:startall");
            s.style.display = "inline-block";
        }
    </script>
    <span class="pagetitle">告警管理—— 告警配置管理</span>
    <p:separator/>
    <h:form id="fsearch">
        <p:growl id="growl" showDetail="true" sticky="false" life="1000"/>
        <p:panel id="panel0" header="查询添加" style="margin-bottom:10px;">
            <p:dataTable id="dlist0" var="l" resizableColumns="true"
                         value="#{biMonitorConfigAction.monitorConfigEntity}">
                <!-- 	<p:column headerText="表名">
                    <h:inputText value="#{l.tableName}" styleClass="fullwidth" />
                </p:column>
                <p:column headerText="字段名">
                    <h:inputText value="#{l.filedName}" styleClass="fullwidth" />
                </p:column>
                <p:column headerText="字段值">
                    <h:inputText value="#{l.filedValue}"  styleClass="fullwidth" />
                </p:column>
                <p:column headerText="分组名">
                    <h:inputText value="#{l.groupName}"  styleClass="fullwidth" />
                </p:column>
                 -->
                <p:column headerText="监控描述" style="width:200px">
                    <h:inputText value="#{l.description}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="操作" styleClass="column" style="width:150px">
                    <p:commandButton value="查询"
                                     action="#{biMonitorConfigAction.searchByCriteria()}"
                                     update=":datalist:panel1"/>
                    <p:commandButton value="添加"
                                     action="#{biMonitorConfigAction.addEntityMonitorConfig()}"
                                     update=":datalist:panel1 :fsearch:growl"/>
                </p:column>
                <p:column headerText="监控语句" style="width:400px">
                    <p:inputTextarea value="#{l.inquerySQL}" styleClass="fullwidth" style="height: 80px;"/>
                </p:column>
                <p:column headerText="监控阈值" style="width:100px">
                    <h:inputText value="#{l.threshHold}" styleClass="fullwidth"/>
                </p:column>
                <!-- 	<p:column headerText="监控类型" styleClass="column">
                    <p:selectOneMenu value="#{l.inqueryType}">
                        <f:selectItem itemLabel="请选择" itemValue="0" />
                        <f:selectItem itemLabel="求和" itemValue="1" />
                        <f:selectItem itemLabel="分组求和" itemValue="2" />
                    </p:selectOneMenu>
                </p:column> -->
                <p:column headerText="开始日期" styleClass="column" style="width:180px">
                    <p:calendar value="#{l.startTime}" mode="popup"
                                pattern="yyyy-MM-dd HH:mm:ss"/>
                </p:column>
                <p:column headerText="结束日期" styleClass="column" style="width:180px">
                    <p:calendar value="#{l.endTime}" mode="popup"
                                pattern="yyyy-MM-dd HH:mm:ss"/>
                </p:column>
                <p:column headerText="监控频率(分钟)" style="width:120px">
                    <h:inputText value="#{l.intervalTime}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="监控次数" style="width:100px">
                    <h:inputText value="#{l.countNum}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="监控产出说明" style="width:100px">
                    <h:inputText value="#{l.subDescription}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="监控组别" style="width:200px" styleClass="column">
                    <p:selectOneMenu value="#{l.groupId}" label="请选择">
                        <f:selectItems value="#{biMonitorConfigAction.groupMap.entrySet()}" var="entry"
                                       itemLabel="#{entry.value.groupName}" itemValue="#{entry.key}"/>
                    </p:selectOneMenu>
                </p:column>

            </p:dataTable>
        </p:panel>
    </h:form>
    <br/>


    <h:form id="datalist">
        <p:growl id="growl1" showDetail="true" sticky="false" life="1000"/>
        <p:panel id="panel1" header="监控展示" style="margin-bottom:10px;">
            <p:commandButton id="startall" value="开始所有任务"
                             action="#{biMonitorConfigAction.startAllEntityMonitorConfig()}"
                             update="dlist growl1" style="height: 35px"/>
            &#160;
            <p:commandButton value="暂停所有任务" onclick="hidedive()"
                             action="#{biMonitorConfigAction.pauseAllEntityMonitorConfig()}"
                             update="dlist growl1" style="height: 35px;margin-bottom: 10px;margin-top: 5px"/>
            &#160;
            <p:commandButton value="恢复所有任务" onclick="showdive()"
                             action="#{biMonitorConfigAction.resumeAllEntityMonitorConfig()}"
                             update="dlist growl1" style="height: 35px;margin-bottom: 10px;margin-top: 5px"/>
            <p:dataTable id="dlist" var="l"
                         value="#{biMonitorConfigAction.monitorConfigEntityList}"
                         resizableColumns="true" paginator="true" paginatorPosition="top" scrollable="true"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}"
                         rowsPerPageTemplate="15,30" rows="15" style="text-align:center;">
                <f:facet name="{Exporters}">
                    <h:commandLink styleClass="exporter">
                        <p:graphicImage url="/resources/images/excel.png" height="25px"/>
                        <p:dataExporter type="xls" target="dlist"
                                        fileName="MonitorConfig-#{pageHelper.getNewDateDetailStr()}"/>
                    </h:commandLink>
                </f:facet>
                <p:column headerText="监控id" styleClass="column" style="width:100px">
                    <h:outputText value="#{l.id}"/>
                </p:column>
                <p:column headerText="监控状态" styleClass="column" style="width:100px">
                    <h:outputText
                            value="#{biMonitorConfigAction.getStatusStr(l.status)}"/>
                </p:column>
                <p:column headerText="监控描述" style="width:200px">
                    <h:inputText value="#{l.description}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="监控阈值" style="width:100px">
                    <h:inputText value="#{l.threshHold}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="操作" styleClass="column" style="width:200px">
                    <p:commandButton value="修改"
                                     action="#{biMonitorConfigAction.modifyEntityMonitorConfig(l)}"
                                     update=":datalist"/>
                    <p:commandButton value="暂停"
                                     action="#{biMonitorConfigAction.pauseScheduleJob(l.id)}"
                                     rendered="#{l.status == 'NORMAL' or l.status == 'BLOCKED'}"
                                     update=":datalist"/>
                    <p:commandButton value="恢复"
                                     action="#{biMonitorConfigAction.resumeScheduleJob(l)}"
                                     rendered="#{l.status == 'PAUSED'}" update=":datalist"/>
                    <p:commandButton value="停止"
                                     action="#{biMonitorConfigAction.delEntityMonitorConfig(l.id)}"
                                     update=":datalist" rendered="#{l.status != 'NONE' and l.status != 'COMPLETE'}"/>
                </p:column>
                <!-- <p:column headerText="表名">
                        <h:inputText value="#{l.tableName}" styleClass="fullwidth" />
                    </p:column>
                    <p:column headerText="字段名">
                        <h:inputText value="#{l.filedName}" styleClass="fullwidth" />
                    </p:column>
                    <p:column headerText="字段值">
                        <h:inputText value="#{l.filedValue}" styleClass="fullwidth" />
                    </p:column>
                    <p:column headerText="分组名">
                        <h:inputText value="#{l.groupName}" styleClass="fullwidth" />
                    </p:column>
                <p:column headerText="监控类型" styleClass="column" style="width:100px">
                        <p:selectOneMenu value="#{l.inqueryType}">
                            <f:selectItem itemLabel="请选择" itemValue="0" ajax="false"/>
                            <f:selectItem itemLabel="求和" itemValue="1" ajax="false"/>
                            <f:selectItem itemLabel="分组求和" itemValue="2" ajax="false"/>
                        </p:selectOneMenu>
                    </p:column> -->
                <p:column headerText="监控语句" style="width:200px">
                    <p:inputTextarea value="#{l.inquerySQL}" style="height:30px;" onblur="
                            this.style = 'height:30px;';"
                                     onfocus=" this.style = 'height:auto;';" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="开始日期" styleClass="column" style="width:180px">
                    <p:calendar value="#{l.startTime}" mode="popup"
                                pattern="yyyy-MM-dd HH:mm:ss"/>
                </p:column>
                <p:column headerText="结束日期" styleClass="column" style="width:180px">
                    <p:calendar value="#{l.endTime}" mode="popup"
                                pattern="yyyy-MM-dd HH:mm:ss"/>
                </p:column>
                <p:column headerText="监控频率(分钟)" style="width:120px">
                    <h:inputText value="#{l.intervalTime}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="监控次数" style="width:100px">
                    <h:inputText value="#{l.countNum}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="监控产出说明" style="width:100px">
                    <h:inputText value="#{l.subDescription}" styleClass="fullwidth"/>
                </p:column>
                <p:column headerText="监控组别" style="width:200px" styleClass="column">
                    <p:selectOneMenu value="#{l.groupId}" label="请选择">
                        <f:selectItems value="#{biMonitorConfigAction.groupMap.entrySet()}" var="entry"
                                       itemLabel="#{entry.value.groupName}" itemValue="#{entry.key}"/>
                    </p:selectOneMenu>
                </p:column>

            </p:dataTable>
        </p:panel>
    </h:form>
</h:body>
</html>
